VLOG_OPTS = +libext+.v  \
	+libext+.sv  \
	$(SVERILOG_OPT) \
	+no_notifier  \
	+warn=noTMR  \
	+lint=all,noTMR,noVCDE,noIEELMME,noIWU,noZERO  \
	+v2k  \
        +incdir+$(DES_DIR) \
	+incdir+$(TB_DIR) \
	-debug_pp \
        -notice \
        -R \

HDL_FILES = \
        $(DES_DIR)/*.v \
        $(TB_DIR)/$(TB_FILE) \

LIB_DIRS = -y $(DES_DIR)

DES_DIR  = ../../des/omicron
TB_DIR   = ../../verif/omicron_tb
ASM_DIR  = ../../verif/asm
TB_FILE  = omicron_tb.v
VPD_NAME = omicron_tb.vpd
TST      = opcode_add_tst1
RUN      = run
V        = 
VCS      := $(shell which vcs)

# Look to see if vcs is installed
ifeq ($(VCS),)
RUN = run_i
endif

%.asm:
	../../pl/compiler.pl $(*F) $(ASM_DIR)
	cp $(*F)-work/$(*F).hex imem.txt
	cp $(ASM_DIR)/generic_dmem.txt dmem.txt
	- cp $(ASM_DIR)/$(*F).mem dmem.txt
	make $(RUN) TST=$(*F)

run_i:
	iverilog $(V) -DIVERILOG -somicron_tb -g2001 -I $(DES_DIR) -tvvp -Wall -Wno-timescale $(HDL_FILES) | tee "$(TST).log"
	vvp $(V) a.out

run:
	vcs \
	$(VLOG_OPTS) \
        $(LIB_DIRS) \
        +vpdfile+$(VPD_NAME) \
        -l $(TST).log \
	$(TB_DIR)/$(TB_FILE)

view:
	gtkwave omicron_tb.vcd

CLEAN:
	rm -rf csrc simv simv.daidir *.log *.vpd *.vcd .vcsmx_rebuild imem.txt dmem.txt *-work *.out
